<template>
    <div class="my-container">
        <van-cell-group v-if="user" class="my-info">
            <van-cell
                class="base-info"
                center
                :border="false"
            >
                <van-image 
                    class="avatar"
                    slot="icon"
                    round
                    fit="cover"
                    :src="currentUser.photo"
                />
                <div class="name" slot="title">
                    {{currentUser.name}}
                </div>
                <van-button
                    class="update-btn"
                    size="small"
                    round
                    to="/user/profile"
                >编辑</van-button>
            </van-cell>
            <van-grid class="data-info" :border="false">
                <van-grid-item class="data-info-item">
                    <div class="text-wrap" slot="text">
                        <div class="count">1</div>
                        <div class="text">头疼</div>
                    </div>
                </van-grid-item>
                <van-grid-item class="data-info-item">
                    <div class="text-wrap" slot="text">
                        <div class="count">1</div>
                        <div class="text">头疼</div>
                    </div>
                </van-grid-item>
                <van-grid-item class="data-info-item">
                    <div class="text-wrap" slot="text">
                        <div class="count">1</div>
                        <div class="text">头疼</div>
                    </div>
                </van-grid-item>
                <van-grid-item class="data-info-item">
                    <div class="text-wrap" slot="text">
                        <div class="count">1</div>
                        <div class="text">头疼</div>
                    </div>
                </van-grid-item>

            </van-grid>
        </van-cell-group>

        <div v-else class="not-login">
            <div
                @click="$router.push({name:'login', query: {redirect:'/my'}})"
            >
                <img src="" class="mobile">
            </div>
            <div class="text"> 登录 / 注册</div>
        </div>

        <van-grid>
            <van-grid-item
                class="nav-grid-item"
                icon-prefix="toutiao"
                icon="shoucang"
                text="收藏"
            />
            <van-grid-item
                class="nav-grid-item"
                icon-prefix="toutiao"
                icon="lishi"
                text="历史"
            />
        </van-grid>

        <van-cell
            title="消息通知" is-link to="/"
        />

        <van-cell 
            class="mb-4"
            title="小智同学"
            is-link
            to="/user/chat"
        />
        <van-cell
            v-if="user"
            class="logout-cell"
            title="退出登录"
            @click="onLogout"
        />
    </div>
</template>

<script>
export default {
    data() {
    },

    methods: {

        onLogout () {
            this.$dialog.confirm({
                title: '退出提示',
                message: '确认退出吗？'
            })
                .then(()=>{
                    this.$store.commit('setUser', null)
                })
                .catch(()=>{

                })
        }
    }
}
</script>
